package com.ibeeking.gmc.job.core.enums;

import org.springframework.util.StringUtils;

/**
 *
 */
public enum JobTypeEnum {

    /**
     * 持续性任务
     */
    CONTINUE_JOB(1, "Continue Job"),

    /**
     * 一次性任务
     */
    ONCE_JOB(2, "Once Job");

    private Integer value;
    private String title;

    private JobTypeEnum(Integer value, String title) {
        this.value = value;
        this.title = title;
    }

    public Integer getValue() {
        return value;
    }

    public void setValue(Integer value) {
        this.value = value;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getTitle() {
        return title;
    }

    public static JobTypeEnum match(String name, JobTypeEnum defaultItem) {
        if (!StringUtils.isEmpty(name)) {
            for (JobTypeEnum item : JobTypeEnum.values()) {
                if (item.name().equals(name)) {
                    return item;
                }
            }
        }
        return defaultItem;
    }
}
